#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MP make_pair
typedef pair<int, int> PII;
typedef vector<int> VI;
struct FindVertex
{
    struct rect
    {
        int x1, y1, x2, y2;
        rect(int a, int b, int c, int d) : x1(a), y1(b), x2(c), y2(d) {}
    };
    vector<rect> rects;
    void add(int a, int b, int c, int d)
    {
        rect r(a, b, c, d);
        rects.push_back(r);
    }
    void solve()
    {
        int i, j;
        VI v;
        for(i = 0; i < rects.size(); i++) {
            v.push_back(rects[i].x1);
            v.push_back(rects[i].x2);
        }
        sort(v.begin(), v.end());
        int k = 0;
        for(i = 0; i < v.size(); i++)
            if(i == 0 || v[i] != v[i-1])
                v[k++] = v[i];
        vector<pair<PII, int> > v1;
        vector<pair<PII, int> > v2;
        for(i = 0; i < rects.size(); i++) {
            int x1 = rects[i].x1, x2 = rects[i].x2;
            int h = rects[i].y2;
            int lo = lower_bound(v.begin(), v.begin()+k, x1) - v.begin();
            int hi = lower_bound(v.begin(), v.begin()+k, x2) - v.begin();
            for(j = lo+1; j <= hi; j++)
                v1.push_back(MP(MP(v[j-1], v[j]), h));
        }
        sort(v1.begin(), v1.end());
        for(i = v1.size()-1; i >= 0; i--)
            if(i == v1.size()-1 || v1[i+1].first != v1[i].first)
                v2.push_back(v1[i]);
        int l = v2.size()-1;
        cout << v2[l].first.first << " " << rects[0].y1 << endl;
        cout << v2[l].first.first << " " << v2[l].second << endl;
        for(i = l; i > 0; i--)
            if(v2[i].second != v2[i-1].second) {
                cout << v2[i].first.second << " " << v2[i].second << endl;
                cout << v2[i-1].first.first << " " << v2[i-1].second << endl;
            }
        cout << v2[0].first.second << " " << v2[0].second << endl;
        cout << v2[0].first.second << " " << rects[0].y1 << endl;
    }
};